﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Processing;
using Cloo;
using Processing.Structures;
using General;

namespace KernelTests
{
    class KernelNix : AKernel
    {
        public Buffer<float> input;
        public Buffer<float> output;


        public override void Dispose()
        {

        }

        protected override bool IsValidInitialized
        {
            get { return true; }
        }

        protected override long[] Dimensions
        {
            get { return new long[] { input.Length }; }
        }

        protected override string ProgramName
        {
            get { return "Nix"; }
        }

        protected override string ProgramSource
        {
            get
            {
                return @"
                    kernel void Nix(
                        global read_only float* input,
                        global write_only float* output
                    )
                    {
                        int i = get_global_id(0);
                        output[i] = input[i] + i;
                    }
                    ";
            }
        }

        protected override void PrepareKernelExecution()
        {
            output = Processor.AllocateBuffer<float>(input.Length);
        }

        protected override void SetArguments()
        {
            SetArgument(0, input);
            SetArgument(1, output, true);
        }

        protected override void FinishKernelExecution()
        {
        }

        public KernelNix(Processor processor) : base(processor) { }
    }
}
